package com.tuojiahr.tools;

/**
 * 说明：
 *
 * @author wang.haibo
 * @date 2012-11-6 下午11:44:54
 */

public class PageUtil {

	private static ThreadLocal<Integer> offset = new ThreadLocal<Integer>();
	private static ThreadLocal<Integer> pagesize = new ThreadLocal<Integer>();
	
	/**
	 * 将offset放入TreadLocal
	 * @param offsetValue
	 */
	public static void setOffset(int offsetValue){
		offset.set(offsetValue);
	}
	
	/**
	 * 从ThreadLocal中获得offset
	 * @return
	 */
	public static int getOffset(){
		Integer offsetValue = offset.get();
		if(null == offsetValue){
			return 0;
		}
		return offsetValue;
	}
	
	/**
	 * 从ThreadLocal中移除offset
	 */
	public static void removeOffset(){
		Integer offsetValue = offset.get();
		if(null != offsetValue){
			offset.remove();
			offset.set(null);
		}
	}
	
	/**
	 * 将pagesize放入TreadLocal
	 * @param offsetValue
	 */
	public static void setPagesize(int pagesizeValue){
		pagesize.set(pagesizeValue);
	}
	
	/**
	 * 从ThreadLocal中获得pagesize
	 * @return
	 */
	public static int getPagesize(){
		Integer pagesizeValue = pagesize.get();
		if(null == pagesize){
			return 0;
		}
		return pagesizeValue;
	}
	
	/**
	 * 从ThreadLocal中移除pagesize
	 */
	public static void removePagesize(){
		Integer pagesizeValue = pagesize.get();
		if(null != pagesizeValue){
			pagesize.remove();
			pagesize.set(null);
		}
	}
}
